//******************************************************************************
//Copyright(C) 2020-2021 zhejiang zhida dianzikeji Co., Ltd
//浙江智达电子科技有限公司
//File name:      variable.h
//Author:         zzg
//Version:        Ver0.1
//Date:           2021-4-25
//Description:    全局头文件调用/全局宏定义声明/全局变量声明
//History:
//******************************************************************************

#ifndef __MOF_SM5235E_DRV_H__
#define __MOF_SM5235E_DRV_H__

#include <mof_stdint.h>
#include <bathheater_app.h>

//#define NUMBER_OF_CHIPS 24

#define FRAME_BITS_TOTAL (12+(NUMBER_OF_CHIPS*96)+48+8)

#define FRAME_BITS_DATA_FULL 133
#define FRAME_BITS_DATA_H ((FRAME_BITS_DATA_FULL*3)/4)
#define FRAME_BITS_DATA_L ((FRAME_BITS_DATA_FULL*1)/4)
#define FRAME_BITS_DATA_ZERO 0



typedef struct {
		uint8_t Bytes[12];
	}mof_rgbwy_synchronous_data_t;

	
typedef struct {
	struct {
		uint8_t Bytes[8];
	}verification_code;
	struct {
		uint8_t Bytes[16];
	}out_r;
	struct {
		uint8_t Bytes[16];
	}out_g;
	struct {
		uint8_t Bytes[16];
	}out_b;
	struct {
		uint8_t Bytes[16];
	}out_w;
	struct {
		uint8_t Bytes[16];
	}out_y;
	struct {
		uint8_t Bytes[8];
	}control_data;	
} mof_rgbwy_chip_data_t;
	


typedef union {
	uint8_t Bytes[6];
//	struct{	
//		//Byte0
//		uint8_t verification_code;	

//		uint32_t blank:2;
//		uint32_t r_current_gain:6;
//		uint32_t g_current_gain:6;
//		uint32_t b_current_gain:6;
//		uint32_t w_current_gain:6;
//		uint32_t y_current_gain:6;

//		
//		uint8_t control:2;
//		uint8_t :3;
//		uint8_t pwm_requency:3;
//		
//	} Values;
		
}mof_rgbwy_reg_value_t;


typedef struct {
		uint8_t Bytes[48];
}mof_rgbwy_reg_data_t;

	
typedef struct {
	uint8_t Bytes[8];
}mof_rgbwy_end_data_t;
	



typedef union {
	uint8_t Bytes[FRAME_BITS_TOTAL];
	struct {
		mof_rgbwy_synchronous_data_t sync;
		mof_rgbwy_chip_data_t chips[NUMBER_OF_CHIPS];
		mof_rgbwy_reg_data_t reg;
		mof_rgbwy_end_data_t end;
	}Values;
} mof_rgbwy_frame_t;


typedef struct
{
	mof_rgbwy_frame_t frame;
} mof_sm5235e_t;


void mof_sm5235e_init(mof_sm5235e_t * p_sm5235e);
void mof_sm5235e_fixdata_rgbw(mof_sm5235e_t * p_sm5235e,uint16_t * rout,uint16_t * gout,uint16_t * bout,uint16_t * wout,uint8_t bright);

#endif


